<?php

      $pg = 1; 
      $quant_pg = ceil($quantreg/$numreg);

      
?>


<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
//document.body.fundo.src = <?php echo base_url() ?>"assets/adm/imagens/fundo_confirmacao.png";

function confirmacao(pg,id){
decisao = confirm("Deseja mesmo excluir esse item do menu principal ?\n\
-Caso este item tenha categorias relacionadas, não será possível fazer a exclusão.\n\
-A posição deste item no menu ficará vaga e poderá ser ocupada por outro item.");

if (decisao){
    //ok
window.location="<?php echo base_url()?>meu_painel_de_administracao/menuprincipal/excluir_principal/"+pg+"/"+id;
} else {
    //cancelar
window.location="<?php echo base_url()?>meu_painel_de_administracao/menuprincipal/index/"+pg;
}
}
</SCRIPT>

    
<div class="conteudo">


    <div class="preto_light" <?php if(!empty($bt_criar)){if($bt_criar == 'ok'){echo 'style="display: block"';}}  ?>></div>
    <div class="corpolight" <?php if(!empty($bt_criar)){if($bt_criar == 'ok'){echo 'style="display: block"';}}  ?>>
    
    <?php
    //// ---------- -------- ------ Area para validação de erros ---------- --------------- ------------- ------------------ --------- --------- ---------
    echo validation_errors('<div class="aviso" style="width:100%;background-color:#FFFFCC;
                            font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;height:50px;
                            line-height:50px;text-align:center;z-index:999; position:absolute; "><span style="color:red; 
                            text:center">','</span></div><BR>');
    //// ---------- -------- ------ FIM Area para validação de erros ---------- --------------- ------------- ------------------ --------- --------- ---------
    ?> 
        
        
    <form action="<?php echo (base_url("meu_painel_de_administracao/menuprincipal/adicionar_principal/".($pgg+1)))?>" method="post">
	<div class="titulo-box">Adicionar menu</div>
	<div class="space-box"></div>
   	<div class="nome-campo1">Nome: </div>
        <div class="campo-box"><input type="text" name="nome" maxlength="15" value=""/></div>
   	<div class="space-box"></div>
        <div class="nome-campo2">Ordem: </div>
    	<div class="campo-box">  
            <select name="posi">
                <option value="0">1º</option>
                <option value="1">2º</option>
                <option value="2">3º</option>
                <option value="3">4º</option>
                <option value="4">5º</option>
                <option value="5">6º</option>
                <option value="6">7º</option>
                <option value="7">8º</option>
                <option value="8">9º</option>
                <option value="9">10º</option>
                <option value="n">Não aparecer no menu</option>
            </select> 
            <div class="space-box"></div><div class="space-box"></div>
        </div>
   	<div class="space-box"></div>

        <div class="enviar-box"><input type="image" src="<?php echo base_url('assets/adm/imagens/enviar.png')?>" value="submit"></div>
        </form>
<!--corpolight-->	
</div>

  
    
<!-- ---------------- --------------------------- corpolight CAIXA DE EDIÇÂO  ---------------- --------------------------- -->	
<div class="preto_light-edit" <?php if(!empty($bt_edit)){if($bt_edit == 'ok'){echo 'style="display: block"';}}  ?> ></div>
<div class="corpolight-edit" <?php if(!empty($bt_edit)){if($bt_edit == 'ok'){echo 'style="display: block"';}}  ?> >
    
    <?php
    //// ---------- -------- ------ Area para validação de erros ---------- --------------- ------------- ------------------ --------- --------- ---------
    echo validation_errors('<div class="aviso" style="width:100%;background-color:#FFFFCC;
                            font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;height:50px;
                            line-height:50px;text-align:center;z-index:999; position:absolute; "><span style="color:red; 
                            text:center">','</span></div><BR>');
    //// ---------- -------- ------ FIM Area para validação de erros ---------- --------------- ------------- ------------------ --------- --------- ---------
    ?>
    <?php
    
    if(!empty($id)){}else{$id = null;}
    if(!empty($posi_edit)){}else{$posi_edit = 'n';}
    ?>
    <form action="<?php echo (base_url("meu_painel_de_administracao/menuprincipal/salva_principal/".($pgg+1).'/'.$id.'/'.$posi_edit))?>" method="post">
	<div class="titulo-box">Editar menu</div>
	<div class="space-box"></div>
    	<div class="nome-campo1">Nome: </div>
        <div class="campo-box"><input type="text" name="nome" maxlength="15" value="<?php if(!empty($nome_edit)){echo $nome_edit;} ?>"/></div>
        <div class="space-box"></div>
        <div class="nome-campo2">Ordem: </div>
        
        <?php 
        
        if($posi_edit == '0'){$posi_posi = "1º";}else
        if($posi_edit == '1'){$posi_posi = "2º";}else
        if($posi_edit == '2'){$posi_posi = "3º";}else
        if($posi_edit == '3'){$posi_posi = "4º";}else
        if($posi_edit == '4'){$posi_posi = "5º";}else
        if($posi_edit == '5'){$posi_posi = "6º";}else
        if($posi_edit == '6'){$posi_posi = "7º";}else
        if($posi_edit == '7'){$posi_posi = "8º";}else
        if($posi_edit == '8'){$posi_posi = "9º";}else
        if($posi_edit == '9'){$posi_posi = "10º";}else
        if($posi_edit == 'n'){$posi_posi = "Não aparecer no menu";}
        
        ?>
        
     	<div class="campo-box">  
            <select name="posi">
                <?php echo '<option value="'.$posi_edit.'">'.$posi_posi.'</option>' ;?>
                <?php if ($posi_edit == 0){}else{echo '<option value="0">1º</option>';} ?>
                <?php if ($posi_edit == 1){}else{echo '<option value="1">2º</option>';} ?>
                <?php if ($posi_edit == 2){}else{echo '<option value="2">3º</option>';} ?>
                <?php if ($posi_edit == 3){}else{echo '<option value="3">4º</option>';} ?>
                <?php if ($posi_edit == 4){}else{echo '<option value="4">5º</option>';} ?>
                <?php if ($posi_edit == 5){}else{echo '<option value="5">6º</option>';} ?>
                <?php if ($posi_edit == 6){}else{echo '<option value="6">7º</option>';} ?>
                <?php if ($posi_edit == 7){}else{echo '<option value="7">8º</option>';} ?>
                <?php if ($posi_edit == 8){}else{echo '<option value="8">9º</option>';} ?>
                <?php if ($posi_edit == 9){}else{echo '<option value="9">10º</option>';} ?>
                <?php if ($posi_edit == 'n'){}else{echo '<option value="n">Não aparecer no menu</option>';} ?>

            </select> 
            <div class="space-box"></div><div class="space-box"></div>
        </div>       
        <div class="enviar-box"><input type="image" src="<?php echo base_url('assets/adm/imagens/salvar2.png')?>" value="submit"></div>
        </form>
<!-- ---------------- --------------------------- corpolight FIM CAIXA DE EDIÇÂO  ---------------- --------------------------- -->	
</div>





    <?php
    //// ---------- -------- ------ Area para mensagens do sistema "DEU CERTO"  ---------- --------------- ------------- ------------------ --------- --------- ---------
        if($this->session->flashdata('mensagemok')){
        echo '<center>';
        echo '<BR><div class="ao" style="width:900px;background-color:#FFFFCC;
            font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;height:50px;
            line-height:50px;text-align:center;z-index:999;position:absolute;">'.$this->session->flashdata('mensagemok').'</div><BR>';
        echo '</center>';
        }   
    //// ---------- -------- ------ FIM Area para mensagens do sistema "DEU CERTO" ---------- --------------- ------------- ------------------ --------- --------- ---------
    ?> 
    <?php
    //// ---------- -------- ------ Area para mensagens do sistema  "DEU ERRADO" ---------- --------------- ------------- ------------------ --------- --------- ---------
        if($this->session->flashdata('mensagemerro')){
        echo '<center>';
        echo '<BR><div class="ao" style="width:900px;background-color:#FFFFCC;
            font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;height:50px;
            line-height:50px;text-align:center;z-index:999;position:absolute;"><span style="color:red; text:center">'
            .$this->session->flashdata('mensagemerro').'</span></div><BR>';
        echo '</center>';
        }   
    //// ---------- -------- ------ FIM Area para mensagens do sistema "DEU ERRADO" ---------- --------------- ------------- ------------------ --------- --------- ---------
    ?> 


<div class="bt-criar-dica"><a href="#"><img src="<?php echo base_url('assets/adm/imagens/add-menu.png')?>" width="116" height="28"  /></a></div>
<div class="top-menu"></div>
    <div class="clear"></div>
  <div class="cont-anuncio">
    
    <div class="content">

        
        
<table width="960" border="1" cellspacing="0" cellpadding="0" bordercolor="#CCCCCC" align="center">
  <tr>
  	<th align="center"><strong></strong>Cód.</th>
        <th align="center"><strong style="padding-right:500px; text-align: center">Menus</strong></th>
        <th align="center" style="width: 12%">Posição</th>
        <th align="center"><strong>Opções</strong></th>
    </tr>        
        
    <?php
    

    foreach ($registro as $cat){
        
        if($cat->cate_posicao == '0'){$posi_posii = "1º";}else
        if($cat->cate_posicao == '1'){$posi_posii = "2º";}else
        if($cat->cate_posicao == '2'){$posi_posii = "3º";}else
        if($cat->cate_posicao == '3'){$posi_posii = "4º";}else
        if($cat->cate_posicao == '4'){$posi_posii = "5º";}else
        if($cat->cate_posicao == '5'){$posi_posii = "6º";}else
        if($cat->cate_posicao == '6'){$posi_posii = "7º";}else
        if($cat->cate_posicao == '7'){$posi_posii = "8º";}else
        if($cat->cate_posicao == '8'){$posi_posii = "9º";}else
        if($cat->cate_posicao == '9'){$posi_posii = "10º";}else
        if($cat->cate_posicao == 'n'){$posi_posii = "<span style='color:red'>Não aparece</span>";}
        
    ?>       

  <tr class="odd">
  	
    <td width="7%" align="center"><?php echo $cat->cate_id ?></td>
    <td width="7%" align="center" style="text-align: left; padding:   5px"><?php echo $cat->cate_nome ?></td>
    <td width="7%" align="center" style="text-align: left; padding:   5px"><?php echo $posi_posii ?></td>
    <td><table width="100%" border="0" cellspacing="5" class="options" cellpadding="0">
     <tr>
              
     	<!--<td height="14"><img src="<?php //echo base_url('assets/adm/imagens/lupa.png')?>" alt="" width="11" height="12" /></td>
        <td><a href="#">Visualizar </a></td> -->
        <td><img src="<?php echo base_url('assets/adm/imagens/lapis.gif')?>" alt="" width="14" height="14" /></td>
        <td><div class="editar-menuu"><a href="<?php echo (base_url("meu_painel_de_administracao/menuprincipal/solicita_dados/".($pgg+1)."/".$cat->cate_id))?>">Editar</a></div></td>
        <td><img src="<?php echo base_url('assets/adm/imagens/close.gif')?>" alt="" width="14" height="14" /></td>
        <td><a href="#" onclick="confirmacao(<?php echo ($pgg+1).",".$cat->cate_id ?>)">Excluir</a></td>
        </tr>
    </table></td>
    
  </tr>
  
    <?php
    
    }
    
    ?>              
 </table>       
        
        
       
        
<?php // -------------------=============---  Paginação -----------------===================------------------------ ?> 
<div class="conteudo">
<table width="100%" border="0" cellspacing="5" class="total" cellpadding="0">
<tr><td colspan="2"></td><td width="40%"></td></tr>
<tr><td colspan="2"></td><td width="40%"></td></tr>
  <tr>
    <td width="19%">&nbsp;</td>
    <td width="6%">&nbsp;</td>
    <td width="40%"></td> 
    <?php $quant_pg = ceil($quantreg/$numreg); ?>
    <?php    
    if ( ($pgg) >= 1) {
    ?>
    <td width="10%"><a href="<?php echo (base_url("meu_painel_de_administracao/menuprincipal/index/".($pgg))); ?>" style="color: white" ><div class="butok3">Anterior</a></div></td>
    <?php
    } else { 
    ?>
    <?php
    }
    ?>  
    <td width="16%">
    <?php
    for($i_pg = 0 ; $i_pg<$quant_pg ; $i_pg++) { 
    if (($pgg <= ($i_pg +2 )) && ($pgg >= ($i_pg -2))){
        if ($pgg == ($i_pg)) {  
    ?>              
    <div class="box-n"><span class=pgoff><?php echo $i_pg+1 ?></span></div>
    <?php   } else {
                        $i_pg2 = $i_pg;
    ?>
    <div class="box-n"><a href="<?php echo (base_url("meu_painel_de_administracao/menuprincipal/index/".($i_pg2+1)))?>" style="color: white"><span class=pgoxx><?php echo ($i_pg +1) ?></span></div></a>            
    <?php   
            }  
        }
    }
    ?> 
    </td>
    <?php       
    if ( ($pgg+2) <= $quant_pg) {
    ?>
    <td width="9%"><div class="butok3"><a href="<?php echo (base_url("meu_painel_de_administracao/menuprincipal/index/".($pgg+2))) ?>" style="color: white">Pr&oacute;ximo</a></div></td>
    <?php
    }
    ?> 
    </tr>
</table>    
</div> 
<?php // -------------------=============---  Paginação -----------------===================------------------------ ?>  
  

        
        
        
        
        
  </div>
    
    
    
    <!--cont-anuncio-->
    </div>
</div>
   
